package testBitmap 
{
	import flash.accessibility.AccessibilityImplementation;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.ProgressEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.net.URLRequest;
	import flash.utils.ByteArray;
	import org.flintparticles.common.displayObjects.Rect;
	
	/**
	 * ...
	 * @author ...
	 */
	public class ImageLoader extends Sprite 
	{
		private var _loader:Loader;
		private var _image:Bitmap;
		private var _byteArray:ByteArray;
		private var _bitmapData:BitmapData;
		
		public function ImageLoader() 
		{
			_loader = new Loader();
            _loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, _onProgressStatus);
            _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onLoaderReady);

            var fileRequest:URLRequest = new URLRequest("assets/1.jpg");
            _loader.load(fileRequest);
		}
		
		public function _onProgressStatus(e:ProgressEvent):void 
		{   
			// this is where progress will be monitored     
			//trace(e.bytesLoaded, e.bytesTotal); 
		}

		public function _onLoaderReady(e:Event):void
		{        
			_bitmapData = new BitmapData(_loader.width, _loader.height);
			_bitmapData.draw(_loader);
			_image = new Bitmap(_bitmapData);
			_image.smoothing = true;
			dispatchEvent(new ImageEvents(ImageEvents.IMAGE_LOADED));
		}
		
		public function get loader():Loader 
		{
			return _loader;
		}
		
		public function get bitmapData():BitmapData 
		{
			return _bitmapData;
		}
	}

}